<template>
	<view class="home">
		<u-navbar @leftClick="leftClick" @rightClick="rightClick" placeholder :safeAreaInsetTop="true" title="流速仪列表"
			:fixed="true" rightIcon="plus">
		</u-navbar>
		<!-- 切换 -->
		<uni-swipe-action ref="swipeAction">
			<uni-swipe-action-item :right-options="options1" @click="cezhanitem($event,item)"
				v-for="(item, index) in cezhanlist" :key="index">
				<view class="topitem" @click="urlCezhan(item)">
					<view class="topname">
						{{item.name}}
					</view>
					<view class="flx">
						<view class="topdik">
							<view class="nubbb">
								{{item.aa}}
							</view>
							<view class="xishu">
								a系数
							</view>
						</view>
						<view class="topdik">
							<view class="nubbb">
								{{item.bb}}
							</view>
							<view class="xishu">
								b系数
							</view>
						</view>
						<view class="topdik">
							<view class="nubbb">
								{{item.cc}}
							</view>
							<view class="xishu">
								C系数
							</view>
						</view>
					</view>

				</view>
			</uni-swipe-action-item>
		</uni-swipe-action>
		<!-- 切换 -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cezhanlist: [],
				options1: [{
					text: '删除',
					style: {
						backgroundColor: '#d54453'
					}
				}]
			}
		},
		onShow() {
			this.cezhanlist = this.vuex_liusuyiList
		},
		onLoad(option) {

		},
		methods: {

			// 返回
			leftClick() {
				uni.navigateBack({
					delta: 1
				});
			},
			// 添加
			rightClick() {
				this.inCezhan()
			},
			urlCezhan(item) {
				uni.navigateTo({
					url: '/pages/channel/currentMeterShow?&id=' + item.id
				});
			},
			cezhanitem(ev, i) {
				let it = i.id
				let arr = this.vuex_liusuyiList
				let index = arr.findIndex(item => item.id == it);
				if (index !== -1) {
					arr.splice(index, 1);
				}
				this.cezhanlist = arr
				uni.$u.vuex('vuex_liusuyiList', arr)
				this.$refs.swipeAction.closeAll()
				// this.cezhanlist = arr
			},
			inCezhan() {
				let ran01 = new Date().getTime()
				uni.navigateTo({
					url: '/pages/channel/currentMeterAdd?&id=' + ran01
				});
			}
		}
	}
</script>
<style scoped lang="scss">
	.topitem {
		width: 650rpx;
		margin: 20rpx auto;
		padding: 0 20rpx 20rpx 20rpx;
		border-radius: 30rpx;
		border: #ffffff solid 3rpx;
		box-shadow: 2rpx 2rpx 10rpx 2rpx #cad0d9;
		background-color: #d4e6df;
		// background-color: #f4f6f8;

		.topname {
			font-size: 50rpx;
			// padding: 15rpx;
			color: #ffffff;
			text-align: center;
			margin: 20rpx 0;
			border-radius: 20rpx;
			border-bottom: #c6d5da solid 2rpx;
			background-color: #46b345;
		}

		.flx {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.topdik {
				text-align: center;
				font-size: 40rpx;
				padding: 20rpx 30rpx;
				// background-color: #46b345;
				background-color: #ffffff;
				border-radius: 20rpx;
				.xishu {
					color: #46b345;
				}

				.nubbb {
					font-size: 50rpx;
					color: #000000;
				}
			}
		}

	}

	.u-page {
		padding: 0;
	}

	.u-demo-block__title {
		padding: 10px 0 2px 15px;
	}

	.swipe-action {
		&__content {
			padding: 25rpx 0;

			&__text {
				font-size: 15px;
				color: $u-main-color;
				padding-left: 30rpx;
			}
		}
	}
</style>
<style>
	page {
		/* background-color: #f8f8f8; */
	}
</style>